Avoid duplicate temperature compensation in EAHRS#30863
Avoid duplicate temperature compensation in EAHRS#30863ohyaiamhere wants to merge 3 commits intoArduPilot:masterfrom
Conversation
34370d4 to
67075aa
Compare
3f98453 to
9a97e14
Compare
e994bc3 to
9ff73df
Compare
9ff73df to
0f88775
Compare
1afaa03 to
bfa153d
Compare
peterbarker
left a comment
There was a problem hiding this comment.
Why are the temperature calibration values non-zero for the external device?
96976bb to
edcb31b
Compare
Hello Peter, The function I had created earlier was not correctly attaching the I have modified the commit to deal with this issue. |
peterbarker
left a comment
There was a problem hiding this comment.
This is only a partial review - just want to make sure I know what you're trying to do here.
So I think what you're trying to do here is cope with the fact that Microstrain can supply IMU data which has already been adjusted for the temperatures in which the microstrain is operating?
... and that thus you do not want to learn any offsets from the microstrain when we are learning?
Thing is that I'm pretty sure there are many dragons with using tcal and externalahrs IMU data.
I'm particularly concerned about what happens if you disable the IMU data from the externalahrs - do we start to apply the learnt coefficients to the wrong IMU now?!
3059ee9 to
dd16037
Compare
618f891 to
a56db9b
Compare
peterbarker
left a comment
There was a problem hiding this comment.
OK, so this is much simpler than it was :-)
We'll need a report on what testing has been done for this PR.
| AP_ExternalAHRS::ins_data_message_t ins; | ||
| ins.accel = static_cast<Vector3f>(imu_data.accel); | ||
| ins.gyro = static_cast<Vector3f>(imu_data.gyro); | ||
| ins.temperature = static_cast<float>(-300); |
There was a problem hiding this comment.
.... so you still haven't put this back into the structure... and these casts weren't required before when using the structure.... I think you stopped adding something in here, so perhaps just remove this patch as it doesn't seem to be doing anything.
| ins.accel = static_cast<Vector3f>(imu_data.accel); | ||
| ins.gyro = static_cast<Vector3f>(imu_data.gyro); | ||
| ins.temperature = static_cast<float>(-300); | ||
| ins.TempCalibration = static_cast<AP_ExternalAHRS::TempCal>(AP_ExternalAHRS::TempCal::IsTempCalibrated); |
There was a problem hiding this comment.
Missing the point. Continue to use the structure, cast only what is required when putting data into the structure.
There was a problem hiding this comment.
typedef struct {
Vector3f accel;
Vector3f gyro;
float temperature;
TempCal TempCalibration = TempCal::IsNotTempCalibrated;
} ins_data_message_t;
Due to this modification being added in AP_ExternalAHRS.h the structure cannot be reused in either of the two files. Each time I try to, it throws an error message.
../../libraries/AP_ExternalAHRS/AP_ExternalAHRS_MicroStrain5.cpp: In member function ‘void AP_ExternalAHRS_MicroStrain5::post_imu() const’:
../../libraries/AP_ExternalAHRS/AP_ExternalAHRS_MicroStrain5.cpp:131:9: error: no matching function for call to ‘AP_ExternalAHRS::ins_data_message_t::ins_data_message_t(<brace-enclosed initializer list>)’
131 | };
So another option would be to figure out how to set this default value using another method, and changing this line to
TempCal TempCalibration;
I notice this only in the two MicroStrain drivers but not the others because they use direct assignment, as I had used in the patch before this new one. Like the InertialLabs driver below
state.accel = ins_data.accel;
state.gyro = ins_data.gyro;
fcee1fd to
957b558
Compare
|
@ohyaiamhere Can you add it for SBG driver as well please? SBG's INS are always calibrated in temperature. |
I can create a commit that adds a if (updated_ins) {
cached.sensors.ins_data.accel = state.accel;
cached.sensors.ins_data.gyro = state.gyro;
cached.sensors.ins_ms = now_ms;
AP::ins().handle_external(cached.sensors.ins_data);
}where Although I couldn't find a unit test for this sensor and I do not have the hardware to test it myself, I can make another commit in this pull request. Let me know what you think @peterbarker . |
That sounds good to me. |
I have created the commit. If you have the hardware, would it be possible for you to help test it? |


As explained in issue #25792, there is an issue where EAHRS performs duplicate temperature compensation for certain sensors.
The enum
TempCalibrationof the typeTempCalis adjusted to see if the sensors is of the MicroStrain7 type (as mentioned in the issue) and set the enum asIsTempCalibrated. Else the enum is set asIsNotTempCalibrated.In the inertial sensor section, this enum, which was sent by the message
ins_data_message_t, is checked, and if there is temperature compensation, a new boolIsTempCalibratedis set totrue. This bool then checked at places where temperature compensation due toHAL_INS_TEMPERATURE_CAL_ENABLEoccurs and the code inside is executed if the bool isfalse.